<?php namespace Common\Model;
use Hdphp\Model\Model;

class shopnature extends Model{
	protected $table="shopnature";
	
//	处理商品属性
	public function shopvalue($gid){
//		重组数组
//p(Q('post.'));die;
		$shopvalue=Q('post.attr','');
		$arr=array();
		if(is_array($shopvalue)){
			foreach($shopvalue as $k=>$v){
				if($v!=''){
					$arr[$k]['nature_nid']=$k;
					$arr[$k]['shopvalue']=$v;
					$arr[$k]['goods_gid']=$gid;
				}
			}
			
			
	//		循环添加
			foreach ($arr as $k=>$v){
				$this->add($v);
			}
		}
		
		
		
		$arr1=array();
		$shopprice=Q('post.spec','');
		if(is_array($shopprice)){
			foreach ($shopprice as $k=>$v){
				foreach ($v['value'] as $a=>$b){
					if($b!=''){
						$arr1['nature_nid']=$k;
						$arr1['shopvalue']=$b;
						$arr1['shopprice']=$v['price'][$a];
						$arr1['goods_gid']=$gid;
						$this->add($arr1);
					}
				}
			}
		}	
		return true;
	}
	
}























